package com.openlab.action;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;

public class LoggingThread extends Thread{
	
	private boolean cancleUpdateThread;
	private boolean iscancled = false;
	private Handler loggingHandler;
	
	public LoggingThread(Handler loggingHandler){
		cancleUpdateThread = false;
		this.loggingHandler = loggingHandler;
	}

	public void run() {
		try {									
			while(true){
				Thread.sleep(500);
				if(cancleUpdateThread){
					iscancled=true;					
					return;
				}else{	
					Message msg = new Message();
					Bundle b = new Bundle();
					b.putString("refreshImage", "true");
					msg.setData(b);
					loggingHandler.sendMessage(msg);
				}
			}
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		
	}
	
	public boolean cancle(boolean cancleUpdateThread){
		this.cancleUpdateThread = cancleUpdateThread;
		while(iscancled){			
			return true;
		}
		return true;
	}
}
